﻿@{
    ViewBag.Title = "栏目管理";
}
<div class="header">
    <h1>@ViewBag.Title</h1>
</div>
<ul class="breadcrumb">
    <li>@Html.ActionLink("Home", "Index", "Home")</li>
    <li>@Html.ActionLink("Categorys", "Index")</li>
    <li class="active">User</li>
</ul>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="btn-toolbar">
            <a class="btn btn-primary" href="@Url.Action("Create")" data-toggle="modal" data-target="#modalEdit">
                <i class="fa fa-plus"></i> 添加 栏目
            </a>
            <button class="btn">修改</button>
            <button class="btn">删除</button>
            <div class="btn-group">
            </div>
        </div>
        <div class="well">
            <table id="table"
                   data-url="@Url.Action("List")"
                   data-side-pagination="server"
                   data-toggle="table"
                   data-height="400"
                   data-show-refresh="true"
                   data-minimum-count-columns="2"
                   data-id-field="id"
                   data-page-list="[10, 25, 50, 100, ALL]"
                   data-search="true">
                <thead>
                    <tr>
                        <th data-field="state" data-checkbox="true"></th>
                        <th data-field="Name" data-align="center" data-sortable="true">显示名称</th>
                        <th data-field="Order" data-align="center" data-sortable="true">排序</th>
                        <th data-field="Type" data-align="center" data-sortable="true">类型</th>
                        <th data-field="ActionUrl" data-sortable="true" data-sorter="priceSorter">请求地址</th>
                        <th data-field="Operator" data-sortable="true" data-sorter="priceSorter">操作人</th>
                        <th data-field="OperationTime" data-sortable="true" data-sorter="trur">操作时间</th>
                        <th data-field="operate" data-formatter="operateFormatter" data-events="operateEvents">操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>


@section scripts{
    <script src="~/Scripts/Common.js"></script>
    <script type="text/javascript">
        //修改事件
        function Create() {
            window.parent.addTab("添加栏目", "@Url.Action("Create", "Category")", "icon-page");
        }

        //修改事件
        function Eidt() {
            var rows = $("#article_list").datagrid("getSelections");
            if (!rows || rows.length < 1) {
                $.messager.alert("提示", "请选择要修改的行!");
                return;
            } else if (rows.length !== 1) {
                $.messager.alert("提示", "仅能选择一行!");
                return;
            } else {
                window.parent.addTab("修改文章", "@Url.Action("Edit", "Category")/" + rows[0].Id, "icon-page");
            }
        }

        //删除
        function Delete() {
            var rows = $("#article_list").datagrid("getSelections");
            if (!rows || rows.length < 1) {
                $.messager.alert("提示", "未选择任何行!");
                return;
            } else if (rows.length > 0) {
                $.messager.confirm("确认", "您确定要删除所选行吗？", function(r) {
                    if (r) {
                        $.messager.progress();
                        $.each(rows, function(index, value) {
                            $.ajax({
                                type: "post",
                                url: "@Url.Action("Delete", "Category")",
                                data: { id: value.ModelID },
                                async: false,
                                success: function(data) {
                                }
                            });
                        });
                        $.messager.progress('close');
                        //清除选择行
                        rows.length = 0;
                        $("#article_list").datagrid('reload');
                    }
                });
                return;
            }
        }
    </script>
}
